package inputDemo;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class Demo4 {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = new FileInputStream("d:/test.txt");
        while (true){
            byte[] bytes = new byte[1024];
            int n = inputStream.read(bytes);
            if (n == -1) {
                //读取完毕。n 就是 -1
                break;
            }
            for (int i = 0; i < n; i++) {
                System.out.printf("ox%x ",bytes[i]);
            }
        }
        inputStream.close();
    }
}
